CFLAGS += -Wall -Wextra
CFLAGS += -I/home/yaojiayu/Code/Projects/P01_GateWay
LDFLAGS += -lpaho-mqtt3c

SRCS += $(shell find app -type f -name "*.c")
# SRCS += $(shell find daemon -type f -name "*.c")
# SRCS += $(shell find ota -type f -name "*.c")
SRCS += $(shell find common -type f -name "*.c")
SRCS += $(shell find test -type f -name "*.c")

OBJS = $(SRCS:.c=.o)

TARGET = P01_GateWay


.PHONY: all clean
all: $(TARGET)

$(TARGET): $(OBJS) main.o
	$(CC) $(CFLAGS) -o $@ $^

clean:
	$(RM) $(OBJS) main.o $(TARGET)

buffer_test: $(OBJS) test/buffer_test.o
	-@$(CC) $(CFLAGS) -o $@ $^
	-@./$@
	-@$(RM) $@ $^

mqtt_test: $(OBJS) test/mqtt_test.o
	-@$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
	-@./$@
	-@$(RM) $@ $^

message_test: $(OBJS) test/message_test.o
	-@$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
	-@./$@
	-@$(RM) $@ $^

task_test: $(OBJS) test/task_test.o
	-@$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
	-@./$@
	-@$(RM) $@ $^


